package com.eshop.modules;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    static int N = 100000100;
    static int[] st = new int[N];
    public static void main(String[] args) throws Exception {
        BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(sc.readLine().trim());
        int max = 0;
        int min = 0;
        
        for(int i=0;i<n;i++){
            String[] values = sc.readLine().split("\\s+");
            for(int j=0;j<values.length;j++){
                int value = Integer.parseInt(values[j]);
                max = Math.max(max,value);
                min = Math.min(min,value);
                st[value]++;
            }
        }
        
        int duan = 0;
        int chong = 0;
        
        for(int i=min;i <= max;i++){
            int value = st[i];
            if(value==0) duan=i;
            if(value==2) chong=i;
        }
        
        System.out.println(duan+" "+chong);
        
    }
}